#include <stdio.h>
#include <stdlib.h>

#define MAX_SIZE 100

struct MinStack {
    int top;
    int data[MAX_SIZE];
    int minData[MAX_SIZE];
};

void initMinStack(struct MinStack* minStack) {
    minStack->top = -1;
}

int isEmpty(struct MinStack* minStack) {
    return minStack->top == -1;
}

int isFull(struct MinStack* minStack) {
    return minStack->top == MAX_SIZE - 1;
}

void push(struct MinStack* minStack, int item) {
    if (isFull(minStack)) {
        printf("Error: Stack is full\n");
        return;
    }
    minStack->data[++(minStack->top)] = item;
    if (isEmpty(minStack) || item < minStack->minData[minStack->top - 1]) {
        minStack->minData[minStack->top] = item;
    } else {
        minStack->minData[minStack->top] = minStack->minData[minStack->top - 1];
    }
}

int pop(struct MinStack* minStack) {
    if (isEmpty(minStack)) {
        printf("Error: Stack is empty\n");
        return -1;
    }
    minStack->top--;
    return minStack->data[minStack->top + 1];
}

int getMin(struct MinStack* minStack) {
    if (isEmpty(minStack)) {
        printf("Error: Stack is empty\n");
        return -1;
    }
    return minStack->minData[minStack->top];
}

int main() {
    struct MinStack minStack;
    initMinStack(&minStack);

    push(&minStack, 5);
    push(&minStack, 2);
    push(&minStack, 4);
    push(&minStack, 1);

    printf("Minimum element: %d\n", getMin(&minStack));

    printf("Pop element: %d\n", pop(&minStack));
    printf("Minimum element: %d\n", getMin(&minStack));

    return 0;
}